import { createApp } from 'vue'
import App from './App.vue'
import router from './router'

import { 
  renderWithQiankun,
  qiankunWindow
} from 'vite-plugin-qiankun/dist/helper'
// createApp(App).mount('#app')
let app = null
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {//判断qiankun是否启动
  app = createApp(App)
  app.use(router).mount('#app')
} else { 
  renderWithQiankun({
    mount(props) {
      console.log("vue应用挂载")
      console.log('vue props', props)
      const {  container } = props
      app = createApp(App)
      app.use(router).mount(container?container.querySelector('#app'):document.querySelector('#app'))
     },//props 配置中的内容
    bootstrap() {
      console.log("vue应用初始化")
     },
    update() {
      console.log("vue应用更新")
     },
    unmount() { 
      console.log("vue应用卸载")
      app.unmount()
      app = null
    }
  })
}